//
// Created by fanghr on 17-12-24.
//

#ifndef PROJECT_IMU_FRAME_H
#define PROJECT_IMU_FRAME_H

#include "imu_protocal.h"
#include "../../include.h"

class imu_frame {
public:
    struct table_t {
        friend class boost::serialization::access;

        imu_acceleration::table_t acceleration;
        imu_angle::table_t angle;
        imu_angularVelocity::table_t angularVelocity;
        imu_groundSpeed::table_t groundSpeed;
        imu_latitudeAndLongitudeOutput::table_t latitudeAndLongitudeOutput;
        imu_magneticOutput::table_t magneticOutput;
        imu_portStatus::table_t portStatus;
        imu_pressureAndHeightOutput::table_t pressureAndHeightOutput;
        imu_quaternion::table_t quaternion;
        imu_time::table_t time;

        template<class Archive>
        void serialize(Archive &ar, const unsigned int) {
            ar & acceleration;
            ar & angle;
            ar & angularVelocity;
            ar & groundSpeed;
            ar & latitudeAndLongitudeOutput;
            ar & magneticOutput;
            ar & portStatus;
            ar & pressureAndHeightOutput;
            ar & quaternion;
            ar & time;
        }
    };

private:
    friend class boost::serialization::access;

    table_t table;

    template<class Archive>
    void serialize(Archive &ar, const unsigned int) {
        ar & table;
    }

public:
    imu_frame() {}

    imu_frame(imu_acceleration acceleration,
              imu_angle angle,
              imu_angularVelocity angularVelocity,
              imu_groundSpeed groundSpeed,
              imu_latitudeAndLongitudeOutput latitudeAndLongitudeOutput,
              imu_magneticOutput magneticOutput,
              imu_portStatus portStatus,
              imu_pressureAndHeightOutput pressureAndHeightOutput,
              imu_quaternion quaternion) {
        table.acceleration = acceleration.get();
        table.angle = angle.get();
        table.angularVelocity = angularVelocity.get();
        table.groundSpeed = groundSpeed.get();
        table.latitudeAndLongitudeOutput = latitudeAndLongitudeOutput.get();
        table.magneticOutput = magneticOutput.get();
        table.portStatus = portStatus.get();
        table.pressureAndHeightOutput = pressureAndHeightOutput.get();
        table.quaternion = quaternion.get();
    }

    table_t get() {
        return table;
    }
};


#endif //PROJECT_IMU_FRAME_H
